import os
import subprocess

def kill_process(process_name):
    try:
        # 在Windows上执行taskkill命令
        subprocess.check_call(['taskkill', '/IM', process_name, '/F'])
        print(f"Process {process_name} has been terminated.")
    except subprocess.CalledProcessError as e:
        print(f"Failed to terminate process {process_name}. Error: {e}")

if __name__ == "__main__":
    kill_process("localServer.exe")